Package com.fsf.news.controller
Class NewsControllerTest
java.lang.Object
com.fsf.news.controller.NewsControllerTest
@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class)
class NewsControllerTest
extends Object
Unit tests for the NewsController class.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) com.fsf.news.controller.NewsController(package private) com.fsf.news.view.html.ErrorView(package private) play.data.Form<com.fsf.news.model.form.NewsForm> (package private) play.data.FormFactory(package private) play.twirl.api.Html(package private) play.i18n.Messages(package private) play.i18n.MessagesApi(package private) play.mvc.Http.Request(package private) play.mvc.Result(package private) com.fsf.news.service.NewsService(package private) play.mvc.Http.Session(package private) com.fsf.news.view.html.SourceProfileView(package private) play.data.Form<com.fsf.news.model.form.NewsSourcesForm> (package private) com.fsf.news.service.NewsSourcesService(package private) com.fsf.news.view.html.NotilyticsView(package private) com.fsf.news.view.html.WordStatsView -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidTests that the error method renders the error HTML view.(package private) voidTests that the index method redirects to the NotiLytics page.(package private) voidTests that the notilytics method renders the NotiLytics HTML view with an existing session.(package private) voidTests that the notilytics method renders the NotiLytics HTML view with a new session.(package private) voidTests that the search method searches for news based on the provided form data and returns the rendered NotiLytics HTML view.(package private) voidTests that the search method throws an InvalidSessionException when no session ID is available.(package private) voidTests that the sourceByName method retrieves a source profile and renders the corresponding HTML view.(package private) voidTests that the sources method searches for sources based on the provided form data and returns the rendered NotiLytics HTML view.(package private) voidTests that the sources method throws an InvalidSessionException when no session ID is available.(package private) voidTests that the wordStats method retrieves and renders word statistics.(package private) voidTests that the wordStats method throws an InvalidSessionException when no session ID is available.
-
Field Details
-
controller
@InjectMocks com.fsf.news.controller.NewsController controller -
service
@Mock com.fsf.news.service.NewsService service -
sourcesService
@Mock com.fsf.news.service.NewsSourcesService sourcesService -
view
@Mock com.fsf.news.view.html.NotilyticsView view -
wordStatsView
@Mock com.fsf.news.view.html.WordStatsView wordStatsView -
sourceProfileView
@Mock com.fsf.news.view.html.SourceProfileView sourceProfileView -
errorView
@Mock com.fsf.news.view.html.ErrorView errorView -
formFactory
@Mock play.data.FormFactory formFactory -
form
@Mock play.data.Form<com.fsf.news.model.form.NewsForm> form -
sourcesForm
@Mock play.data.Form<com.fsf.news.model.form.NewsSourcesForm> sourcesForm -
messagesApi
@Mock play.i18n.MessagesApi messagesApi -
request
@Mock play.mvc.Http.Request request -
session
@Mock play.mvc.Http.Session session -
messages
@Mock play.i18n.Messages messages -
html
@Mock play.twirl.api.Html html -
result
@Mock play.mvc.Result result
-
-
Constructor Details
-
NewsControllerTest
NewsControllerTest()
-
-
Method Details
-
testIndex
@Test void testIndex()Tests that the index method redirects to the NotiLytics page. -
testNotilyticsExistingSession
@Test void testNotilyticsExistingSession()Tests that the notilytics method renders the NotiLytics HTML view with an existing session. -
testNotilyticsNewSession
@Test void testNotilyticsNewSession()Tests that the notilytics method renders the NotiLytics HTML view with a new session. -
testSearch
@Test void testSearch()Tests that the search method searches for news based on the provided form data and returns the rendered NotiLytics HTML view. -
testSearchInvalidSessionException
@Test void testSearchInvalidSessionException()Tests that the search method throws an InvalidSessionException when no session ID is available. -
testSources
@Test void testSources()Tests that the sources method searches for sources based on the provided form data and returns the rendered NotiLytics HTML view. -
testSourcesInvalidSessionException
@Test void testSourcesInvalidSessionException()Tests that the sources method throws an InvalidSessionException when no session ID is available. -
testWordStats
@Test void testWordStats()Tests that the wordStats method retrieves and renders word statistics. -
testWordStatsInvalidSesionException
@Test void testWordStatsInvalidSesionException()Tests that the wordStats method throws an InvalidSessionException when no session ID is available. -
testError
@Test void testError()Tests that the error method renders the error HTML view. -
testSourceByName
@Test void testSourceByName()Tests that the sourceByName method retrieves a source profile and renders the corresponding HTML view.
-